package com.example.sup.conttroller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sup.aspect.annotation.CheckLogin;
import com.example.sup.conttroller.request.PrisonQueryRequest;
import com.example.sup.conttroller.request.QueryTemperRequest;
import com.example.sup.conttroller.response.ServerResponse;
import com.example.sup.entity.*;
import com.example.sup.service.*;
import com.example.sup.vo.CompletePrisonVO;
import com.example.sup.vo.PrisonQueryPageVO;
import com.example.sup.vo.PrisonTemperatureVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName PrisonController
 * @Description {TODO}
 * @Author 李哲
 * @Date 20:32 2024/7/23
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/prison")
public class PrisonController {
    @Resource
    private PrisonService prisonService;
    @Resource
    private EventInfoService evenInfoService;
    @Resource
    private EquipmentInfoService equipmentInfoService;
    @Resource
    private PrisonTypeService prisonTypeService;
    @Resource
    private PrisonJackService prisonJackService;
    @Resource
    private JackInfoService jackInfoService;

    @PostMapping("/queryPage")
    public ServerResponse queryPage(@RequestBody PrisonQueryRequest request) {

        //1.校验参数
        //2.调用service
        Page<PrisonQueryPageVO> page = prisonService.queryPrisonInfo(request);
        //3.返回结果
        return ServerResponse.successWithMsg("查询成功", page);
    }
    @PostMapping("/query")
    @CheckLogin
    public ServerResponse<List<CompletePrisonVO>> query(UserInfo userInfo){
        //1.参数校验
        log.info("登录的用户信息:{}",userInfo);
        //2.调用service
        List<CompletePrisonVO> completePrisonVO =  prisonService.queryCompletePrisonList(userInfo);
        //3.返回Model
        if(completePrisonVO==null||completePrisonVO.size()==0){
            return ServerResponse.failWithMsg("没有完整的监视列表数据");
        }
        return ServerResponse.success(completePrisonVO);
    }
    @PostMapping("queryTemper")
    @CheckLogin
    public ServerResponse queryTemper(UserInfo userInfo,
                                      @RequestBody @Validated QueryTemperRequest queryTemperRequest){
        //1.参数校验
        log.info("登录的用户信息:{}",userInfo);
        //2.调用service---vo
        PrisonTemperatureVO prisonTemperatureVO = prisonService.queryTemper(userInfo,queryTemperRequest);
        log.info("prisonTemperatureVO========>{}",prisonTemperatureVO);
        //3.返回model
        return ServerResponse.success(prisonTemperatureVO);
    }
}
